// Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CLOUDAPPENGINE_CAETOUCHINPUT_H
#define CLOUDAPPENGINE_CAETOUCHINPUT_H

#include <cstdint>
#include <arpa/inet.h>

// SDK传入CAE的触控消息体
typedef struct CaeTouchEventMsg {
    uint8_t id;
    uint8_t action;
    uint16_t x;
    uint16_t y;
    uint16_t pressure;
    int32_t time;
    uint8_t orientation;
    uint16_t height;
    uint16_t width;

    uint8_t GetId()
    {
        return id;
    }

    uint8_t GetAction()
    {
        return action;
    }

    uint16_t GetX()
    {
        return (uint16_t)ntohs(x);
    }

    uint16_t GetY()
    {
        return (uint16_t)ntohs(y);
    }

    uint16_t GetPressure()
    {
        return (uint16_t)ntohs(pressure);
    }

    int32_t GetTime()
    {
        return ntohl(time);
    }

    uint8_t GetOrientation()
    {
        return orientation;
    }

    uint16_t GetWidth()
    {
        return (uint16_t)ntohs(width);
    }

    uint16_t GetHeight()
    {
        return (uint16_t)ntohs(height);
    }
} __attribute__((packed));

// SDK传入CAE的遥控器指令消息体
typedef struct CaeKeyEventMsg {
    uint16_t keycode;
    uint16_t action;
    uint8_t reserved[8];

    uint16_t GetKeycode() {
        return (uint16_t)ntohs(keycode);
    }

    uint16_t GetAction() {
        return (uint16_t)ntohs(action);
    }

} __packed CasKeyEventMsg;

#endif // CLOUDAPPENGINE_CAETOUCHINPUT_H
